package ru.rchervot.sanasar.client.event;

import com.google.gwt.event.shared.GwtEvent;

public class EventSelectedSeveral extends GwtEvent<HandlerSelectedSeveral> {
	private static Type<HandlerSelectedSeveral> TYPE = new Type<HandlerSelectedSeveral>();
	
	private final int numberOfSelectedItems;
	
	public EventSelectedSeveral() {
		numberOfSelectedItems = 0;
	} //TODO why not remove ?
	
	public EventSelectedSeveral(int numberOfSelectedItems) {
		this.numberOfSelectedItems = numberOfSelectedItems;
	}
	
	@Override
	protected void dispatch(HandlerSelectedSeveral handler) {
		handler.onAction(this);
	}

	/**
	 * Gets the type associated with this event.
	 * 
	 * @return returns the handler type
	 */
	public static Type<HandlerSelectedSeveral> getType() {
		if (TYPE == null) {
			TYPE = new Type<HandlerSelectedSeveral>();
		}
		return TYPE;
	}

	public Type<HandlerSelectedSeveral> getAssociatedType() {
		return TYPE;
	}

	public int getNumberOfSelectedItems() {
		return numberOfSelectedItems;
	}
	
	public static EventSelectedSeveral build(int numberOfSelectedItems) {
		return new EventSelectedSeveral(numberOfSelectedItems);
	}

}
